import java.util.Scanner;

public class demo11 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int []arr1=new int[n];
        for (int i = 0; i <n ; i++) {
            arr1[i]=scanner.nextInt();
        }
        int m=scanner.nextInt();
        int []arr2=new int[m];
        for (int i = 0; i <m ; i++) {
            arr2[i]=scanner.nextInt();
        }
        int ret=0;
        int left=0,right=0;
        while (left<n&&right<m){
            if(arr2[right]>=arr1[left]){
                ret++;
                left++;
            }
            right++;
        }
        System.out.println(ret);
    }
}
